flutter delay a function

75

Future.delayed(Duration(milliseconds: 100), () {
  // Do something
});
Future.delayed(const Duration(milliseconds: 500), () {

// Here you can write your code

  setState(() {
    // Here you can write your code for open new view
  });

});
void main() async {
  print('Started at ${DateTime.now()}');
  final time = await Future.delayed(Duration(seconds: 2)).then((value) => DateTime.now());
  print('Awaited time was at $time');
}
Future.delayed(Duration(seconds: 5), (){
      print("Executed after 5 seconds");
});

Comments

Submit
0 Comments